#ifndef _DISCRETEDERIVATIVE_H_
#define _DISCRETEDERIVATIVE_H_

#include <stdint.h>

#define HEATCONTROL_DISCRETEDERIVATIVE_INSTANCE_DECLS \
			static int32_t HeatControl_DiscreteDerivative_previousValue;

#define HeatControl_DiscreteDerivative_initialize() \
			HeatControl_DiscreteDerivative_previousValue = 0

#define HEATCONTROL_DISCRETEDERIVATIVE_LOCAL_DECLS \
			int32_t HeatControl_DiscreteDerivative_value; \
			int32_t HeatControl_DiscreteDerivative_inputValue = 0;

#define HeatControl_DiscreteDerivative_Input_consumeInputValue(value) \
				HeatControl_DiscreteDerivative_inputValue = (value)

#define HeatControl_DiscreteDerivative_computeOutputValues() \
			do { \
				HeatControl_DiscreteDerivative_value = (HeatControl_DiscreteDerivative_inputValue - HeatControl_DiscreteDerivative_previousValue); \
				HeatControl_DiscreteDerivative_value = (HeatControl_DiscreteDerivative_value * 1280 >> 8); \
			} while (0)

#define HeatControl_DiscreteDerivative_Output_getOutputValue() \
				HeatControl_DiscreteDerivative_value

#define HeatControl_DiscreteDerivative_update() \
			HeatControl_DiscreteDerivative_previousValue = HeatControl_DiscreteDerivative_inputValue

#endif /* _DISCRETEDERIVATIVE_H_ */
